home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#34 (Jul 88)
/
Window Sample Stuff
/
FontDialog.Asm
next >
Wrap
Assembly Source File
|
1987-05-06
|
43KB
|
1,205 lines
;------------------------- FontDialog ----------------------------
; Written by Ray.A.Cameron
; Version 1
;Wed May 6, 1987 21:00:51
XDef FontDialog ; Routine's name
XRef FontMap ; Variable's name
;---------- Includes -------------
Include Traps.D ; Use System and ToolBox traps
Include ToolEqu.D ; Use ToolBox Equates
Include QuickEqu.D ; Use QuickDraw Equates
Include SysEqu.D ; Use System Equates
Include PackMacs.Txt ; Use Package Equates
Include FontMacros.Txt ; Use Macro file
; ---------- Equates ----------
FontDPtr Equ A4
FDialog Equ 260 ; Font dialog is DLOG resource #260
ADialog Equ 260 ; Alert dialog is ALRT resource #260
True Equ 1 ; Boolean True
False Equ 0 ; Boolean False
enterCode Equ 3 ; ASCII Enter
bsCode Equ 8 ; ASCII Back Space
crCode Equ 13 ; ASCII Carriage Return
param0 Equ 0 ; Offset to string 0 in DAStrings
param1 Equ 4 ; Offset to string 1 in DAStrings
param2 Equ 8 ; Offset to string 2 in DAStrings
OkActive Equ 0 ; OkActive bit within Dialog Flags
SUpdate Equ 1 ; Sample update bit within Dialog Flags
SRect Equ 2 ; Sample rect bit within Dialog Flags
SKey Equ 3 ; Sample key bit within Dialog Flags
; --------- Font Dialog Data Record -------
DStorage Equ $0 ; Storage for the Dialog Record
TempFont Equ $AA ; Currently selected font number
TempFace Equ $AC ; Currently selected font style
TempSize Equ $AE ; Currently selected font size
DFlags Equ $B0 ; Dialog Flags
NameListH Equ $B2 ; Font Name Selection List's Handle
NameCell Equ $B6 ; Font Name selected cell
SizeListH Equ $BA ; Font Size Selection List's Handle
SizeCell Equ $BE ; Font Size selected cell
TempCell Equ $C2 ; Temporary Cell variable
Item Equ $C6 ; Item's handle or procedure
Itemtype Equ $CA ; Item's type
ItemBox Equ $CC ; Item's enclosing rect
ItemHit Equ $D4 ; Item clicked in dialog
loc_pt Equ $D6 ; mouse location
InitBounds Equ $DA ; Init size of Lists
TextCursor Equ $E2 ; Handle to the IBeam cursor
thename Equ $E6 ; Text string
pnState Equ $1E6 ; Original state of the pen
String1 Equ $1F8 ; Alert text string1
String2 Equ $1FC ; Alert text string2
String3 Equ $200 ; Alert text string3
Sample Equ $204 ; Sample Text Edit Handle
SampleRect Equ $208 ; Sample Text Edit Rect
SampleTicks Equ $210 ; Ticks when Sample required updated
info Equ $214 ; GetFontInfo record
search Equ $21C ; String to search Font Name List
Globalslength Equ $23C
; This routine receives the following inputs:
; teFont: The current font's number
; teFace: The current type face's attributes in the low byte of the word
; Bit 0 - Bold Bit 3 - Outline Bit 6 - Extend
; Bit 1 - Italic Bit 4 - Shadow
; Bit 2 - Underline Bit 5 - Condense
; teSize: The current font's size
; A ModalDialog box is displayed to allow the user to choose the font attributes
; that they desire. If the Ok button, enter key or carriage return is pressed
; the selected values will replace the original values otherwise the values
; remain the same.
FontDialog
Link A6,#0
; Boolean result 20(A6) ; Ok or Cancel
; DtxFont Address 16(A6) ; Address of current Font number
; DtxFace Address 12(A6) ; Address of current Font style
; DtxSize Address 8(A6) ; Address of current Font size
; Return Address 4(A6)
; Old A6 (A6)
Movem.l D0-D7/A0-A4,-(SP) ; Save the existing register values.
Move.w #False,20(A6) ; Set up to return False.
; Create a non-relocatable block for the Font Dialog Data Record.
Move.l #Globalslength,D0
_NewPtr ,CLEAR
Move.l A0,FontDRec(A5) ; Store the pointer.
Movea.l A0,FontDPtr
GetPenState pnState(A4) ; Save the current pen settings.
; Load the present values of the font number, face and size
; into temporary locations.
Movea.l 16(A6),A0 ; Font number.
Move.w (A0),TempFont(A4)
Movea.l 12(A6),A0 ; Font face.
Move.w (A0),TempFace(A4)
Movea.l 8(A6),A0 ; Font size.
Move.w (A0),TempSize(A4)
; Obtain the iBeamCursor's resource and lock it down.
; Function GetCursor (cursorID: Integer): CursHandle
Subq.l #4,SP
Move.w #iBeamCursor,-(SP)
_GetCursor
Move.l (SP)+,TextCursor(A4)
HLock TextCursor(A4)
; Function GetNewDialog (dialogID: Integer; dStorage: Ptr;
; behind: WindowPtr) : DialogPtr
Subq.l #4,SP ; Space for dialog pointer.
Move.w #FDialog,-(SP) ; Identify dialog rsrc #.
Move.l FontDPtr,-(SP) ; Storage area.
Move.l #-1,-(SP) ; Dialog goes on top.
_GetNewDialog
_SetPort
Move.l OneOne,InitBounds+bottom(A4) ; Set InitBounds to (0,0,1,1).
Bset.b #OkActive,DFlags(A4) ; Dialog selections are valid.
; Lock FontMap while its information is being accessed.
HLock FontMap(A5)
DeRefHndle FontMap(A5),A3 ; Dereference the FontMap handle.
;-*- Set up the Style check boxes so that they show the current font's values.
Move.w TempFace(A4),D0 ; Obtain the current face (style) byte.
; Routine SControl (StItem, NofItems, ValueBits : Integer)
Move.w #4,-(SP) ; Item No 4.
Move.w #5,-(SP) ; 5 Items (check boxes).
Move.w D0,-(SP) ; Bits to set.
Bsr SControl
;-*- Set up the Spacing radio buttons so that they show the current fonts values.
Move.w TempFace(A4),D0 ; Obtain the current face (style) byte.
Andi.w #%01100000,D0 ; Examine Condense & Extend.
Bne.s @0 ; If neither of them are set, then
Move.w #%00010000,D0 ; add a bit to represent "Normal".
@0 Lsr.W #4,D0
; Routine SControl (StItem, NofItems, ValueBits : Integer)
Move.w #11,-(SP) ; Item No 11.
Move.w #3,-(SP) ; 3 Items (radio buttons).
Move.w D0,-(SP) ; Bits to set.
Bsr SControl
;-*- Set up the Font Name Selection Window ---------------------------------
GetDItem FontDPtr,#17,Itemtype(A4),Item(A4),ItemBox(A4)
; Function LNew (rView, dataBounds: Rect; cSize: Point; theProc: Integer;
; theWindow: WindowPtr; drawIt, hasGrow, scrollHoriz,
; scrollVert: Boolean): ListHandle
Subq.l #4,SP ; Space for the handle.
Pea ItemBox(A4)
Pea InitBounds(A4) ; Create one cell.
Clr.l -(SP) ; Cell size for text.
Move.w #0,-(SP) ; Text definition procedure.
Move.l FontDPtr,-(SP)
Move.b #False,-(SP) ; drawIt
Move.b #False,-(SP) ; hasGrow
Move.b #False,-(SP) ; scrollHoriz
Move.b #True,-(SP) ; scrollVert
_LNew
Move.l (SP),NameListH(A4) ; Store the List's handle.
DeRefHndle (SP)+,A0 ; Set the selection flags.
Move.b #%10000010,selFlags(A0) ; lOnlyOne, lNoNilHilite
Move.l #$FFFF0000,NameCell(A4) ; (0,-1), no cell is selected.
Jsr LdNames ; Load the Font Names.
;-*- Set up the Font Size Selection Window ---------------------------------
GetDItem FontDPtr,#19,Itemtype(A4),Item(A4),ItemBox(A4)
; Function LNew (rView, dataBounds: Rect; cSize: Point; theProc: Integer;
; theWindow: WindowPtr; drawIt, hasGrow, scrollHoriz,
; scrollVert: Boolean): ListHandle
Subq.l #4,SP ; Space for the handle.
Pea ItemBox(A4)
Pea InitBounds(A4) ; Create one cell.
Clr.l -(SP) ; Cell size for text.
Move.w #0,-(SP) ; Text definition procedure.
Move.l FontDPtr,-(SP)
Move.b #False,-(SP) ; drawIt
Move.b #False,-(SP) ; hasGrow
Move.b #False,-(SP) ; scrollHoriz
Move.b #True,-(SP) ; scrollVert
_LNew
Move.l (SP),SizeListH(A4) ; Store the List's handle.
DeRefHndle (SP)+,A0 ; Set the selection flags.
Move.b #%10000010,selFlags(A0) ; 1OnlyOne, lNoNilHilite
Move.l #$FFFF0000,SizeCell(A4) ; (0,-1), no cell is selected.
Jsr LdSizes ; Load the current Font's Sizes.
;-*- Set up the Font Size Text Edit item -----------------------------------
Jsr SetEditSize
;-*- Set up the Sample Display Text Edit Record -----------------------
GetDItem FontDPtr,#21,Itemtype(A4),Item(A4),SampleRect(A4)
; Function TENew (destRect, viewRect: Rect): TEHandle
Subq.l #4,SP
Pea SampleRect(A4) ; Create a new text edit record.
Pea SampleRect(A4)
_TENew
Move.l (SP)+,Sample(A4) ; Store theTEdit handle.
HLock Sample(A4)
DeRefHndle Sample(A4),A0 ; Setup the variables.
Move.w #teJustCenter,teJust(A0)
Move.b MinusOne,teCROnly(A0)
GetResource 'STR ',#264 ; Obtain the sample text.
HLock (SP) ; Leave the handle on the stack.
DeRefHndle (SP),A0 ; Address of text in A0.
Clr.l D0 ; Length of text in D0.
Move.b (A0)+,D0
; Procedure TEInsert (text: Ptr; Length: LongInt; hTE: TEHandle)
Move.l A0,-(SP) ; Insert the sample string into
Move.l D0,-(SP) ; the record.
Move.l Sample(A4),-(SP)
_TEInsert
HUnlock (SP)+ ; Unlock the string resource.
Jsr SampleWindow ; Update the TEdit variables.
HUnlock Sample(A4)
;-*- Set up the Alert Dialog Variables --------------------------------------
Move.w #-1,ACount ; Reset the Alert stage to 1.
GetResource 'STR ',#261 ; Obtain copies of the Alert strings
Move.l (SP)+,String1(A4) ; handles and store them for easy
GetResource 'STR ',#262 ; access.
Move.l (SP)+,String2(A4)
GetResource 'STR ',#263
Move.l (SP)+,String3(A4)
;-*-*- Display the Dialog Window -*-*---------------------------------------
ShowWindow FontDPtr ; This posts an Activate event.
WaitOk
; Procedure ModalDialog (filterProc: ProcPtr; Var itemHit: Integer);
Pea DUserFilter
Pea ItemHit(A4)
_ModalDialog
Move.w ItemHit(A4),D0 ; Get the itemNo that was Hit.
Subq.w #1,D0 ; Allow for no item zero.
Lsl.w #1,D0 ; *2 for table index.
Move.w ItemTable(D0),D0 ; Point to routine offset
Jmp ItemTable(D0) ; and jump to it.
ItemTable
Dc.w DOk-ItemTable ; Ok Button
Dc.w DCancel-ItemTable ; Cancel Button
Dc.w WaitOk-ItemTable ; Character... Text (Disabled)
Dc.w SStyle-ItemTable ; Bold Check Box
Dc.w SStyle-ItemTable ; Italic Check Box
Dc.w SStyle-ItemTable ; Underline Check Box
Dc.w SStyle-ItemTable ; Outline Check Box
Dc.w SStyle-ItemTable ; Shadow Check Box
Dc.w Style-ItemTable ; Style Text (Enabled)
Dc.w WaitOk-ItemTable ; ThinBox User Item (Disabled)
Dc.w SSpacing-ItemTable ; Normal Radio Button
Dc.w SSpacing-ItemTable ; Condense Radio Button
Dc.w SSpacing-ItemTable ; Extend Radio Button
Dc.w Spacing-ItemTable ; Spacing Text (Enabled)
Dc.w WaitOk-ItemTable ; ThinBox User Item (Disabled)
Dc.w WaitOk-ItemTable ; Font N... Text (Disabled)
Dc.w FontName-ItemTable ; NameSel Wind User Item
Dc.w WaitOk-ItemTable ; Font S... Text (Disabled)
Dc.w FontSize-ItemTable ; SizeSel Wind User Item
Dc.w GetEditSize-ItemTable ; Type size Text Edit Item
Dc.w FontSample-ItemTable ; Sample Font User Item (Disabled)
DOk
; If the current Dialog selection isn't valid, set up the appropriate
; param text strings and invoke the Caution Alert.
Btst.b #OkActive,DFlags(A4) ; Is the selection valid?
Bne @3 ; Yes -> @3
Clr.w D0 ; Set up the three param
Movea.l #DAStrings,A0 ; text strings.
Clr.l param0(A0)
Clr.l param1(A0)
Clr.l param2(A0)
Cmpi.w #-1,TempFont(A4) ; Is TempFont a valid selection?
Bne.s @0 ; Yes -> @0
Bset.b #0,D0 ; No -> include related text.
Move.l String1(A4),param0(A0)
@0 Cmpi.w #0,TempSize(A4) ; Is TempSize a valid selection?
Bne.s @1 ; Yes -> @1
Bset.b #1,D0 ; No -> include related text.
Move.l String2(A4),param2(A0)
@1 Cmpi.w #3,D0 ; If both TempFont and TempSize
Bne.s @2 ; are invalid include the conjunctive
Move.l String3(A4),param1(A0) ; string (String3).
@2 ; Function CautionAlert (alertID: Integer; filterProc: ProcPtr): Integer
Subq.l #2,SP
Move.w #ADialog,-(SP)
Clr.l -(SP)
_CautionAlert
Addq.l #2,SP
Bra WaitOk ; User to alter their selection.
@3 ; If the current Dialog selection is valid, replace the original font
; number, style and size values with the values chosen by the user.
Movea.l 16(A6),A0 ; Font number.
Move.w TempFont(A4),(A0)
Movea.l 12(A6),A0 ; Font style.
Move.w TempFace(A4),(A0)
Movea.l 8(A6),A0 ; Font size.
Move.w TempSize(A4),(A0)
Move.b #True,20(A6) ; Return True.
DCancel
HideWindow FontDPtr
LMDispose NameListH(A4) ; Font Name List.
LMDispose SizeListH(A4) ; Font Size List.
TEDispose Sample(A4) ; Sample Text Edit Record.
CloseDialog FontDRec(A5)
HUnLock FontMap(A5) ; FontMap .
HUnLock TextCursor(A4) ; iBeamCursor resource.
SetPenState pnState(A4) ; Restore the pen settings.
DisposePtr FontDPtr ; Font Dialog Data Record.
Movem.l (SP)+,D0-D7/A0-A4 ; Restore registers.
Unlk A6
Movea.l (SP)+,A0 ; Pop args & return.
Add.l #12,SP
Jmp (A0)
Style
Move.w TempFace(A4),D2 ; Store for comparison later.
Movea.l 12(A6),A0 ; Obtain the original style values
Move.w (A0),D0 ; and retain the lower five bits.
Andi.w #%00011111,D0
Andi.w #%11100000,TempFace(A4) ; Clear the lower 5 bits.
Or.w D0,TempFace(A4) ; Combine the two together.
Bra.s SetStyle
SStyle
Move.w TempFace(A4),D2 ; Store for comparison later.
Move.w ItemHit(A4),D0 ; Get the itemNo that was hit.
Subq.w #4,D0
Bchg.b D0,TempFace+1(A4) ; Toggle the selected item.
SetStyle
Cmp.w TempFace(A4),D2 ; Has the face altered?
Beq.s @1 ; No -> @1
Move.w TempFace(A4),D0
; Routine SControl (StItem, NofItems, ValueBits : Integer)
Move.w #4,-(SP) ; Item No 4.
Move.w #5,-(SP) ; 5 Items (check boxes).
Move.w D0,-(SP) ; Bits to set.
Bsr SControl
Btst.b #OkActive,DFlags(A4) ; Are the Dialog selections valid.
Beq.s @1 ; No, don't update the sample.
Bclr.b #SRect,DFlags(A4) ; Erase the Sample Rect if it hasn't
Beq.s @0 ; been already.
EraseRect SampleRect(A4)
@0 Bset.b #SUpdate,DFlags(A4) ; Sample Window requires updating.
Move.l Ticks,SampleTicks(A4)
@1 Jmp WaitOk
Spacing
Move.w TempFace(A4),D2 ; Store for comparison later.
Movea.l 12(A6),A0 ; Obtain the original style values.
Move.w (A0),D0
Bra.s SetSpacing
SSpacing
Move.w TempFace(A4),D2 ; Store for comparison later.
Move.w ItemHit(A4),D1 ; Get the item No that was hit.
Sub.w #11,D1 ; Produce in D0 a byte that
Move.w #%00010000,D0 ; represents which bit to set.
Lsl.b D1,D0
SetSpacing
Andi.w #%11100000,D0 ; Clear the lower 5 bits.
Andi.w #%00011111,TempFace(A4) ; Clear the top 3 bits.
Or.w D0,TempFace(A4) ; Combine the two together.
Cmp.w TempFace(A4),D2 ; Has the face altered?
Beq.s @2 ; No -> @2
Move.w TempFace(A4),D0 ; Produce in the first 3 bits
Andi.w #%01100000,D0 ; of D0 the settings of the
Bne.s @0 ; 3 radio buttons.
Move.w #%00010000,D0
@0 Lsr.b #4,D0
; Routine SControl (StItem, NofItems, ValueBits : Integer)
Move.w #11,-(SP) ; Item No 11.
Move.w #3,-(SP) ; 3 Items (radio buttons).
Move.w D0,-(SP) ; Bits to set.
Bsr SControl
Btst.b #OkActive,DFlags(A4) ; Are the Dialog selections valid.
Beq.s @2 ; No, don't update the sample.
Bclr.b #SRect,DFlags(A4) ; Erase the Sample Rect if it hasn't
Beq.s @1 ; been already.
EraseRect SampleRect(A4)
@1 Bset.b #SUpdate,DFlags(A4) ; Sample Window requires updating.
Move.l Ticks,SampleTicks(A4)
@2 Jmp WaitOk
SControl
; Routine SControl (StItem, NofItems, ValueBits : Integer)
Link A6,#0
; StItem 12(A6) Start Item number
; NofItems 10(A6) Number of Items
; ValueBits 8(A6) Values of the items
; Return address 4(A6)
; Old A6 (A6)
SetControl
GetDItem FontDPtr,12(A6),Itemtype(A4),Item(A4),ItemBox(A4)
Clr.w D0 ; Set D0 to 1 if the item
Lsr.W 8(A6) ; is to be set or 0 if its not.
Bcc.s @1
Addq.w #1,D0
@1 SetCtlValue Item(A4),D0
Addq.w #1,12(A6) ; Increment the item No counter.
Sub.w #1,10(A6) ; Any more items to process?
Bne.s SetControl ; Yes -> SetControl.
Unlk A6
Movea.l (SP)+,A0 ; Pop args & return.
Add.l #6,SP
Jmp (A0)
FontName
; The user has made a new selection from the Font Name Selection Window,
; either a new font name or none. TempFont will change.
Bclr.b #SRect,DFlags(A4) ; Erase the Sample Rect if it hasn't
Beq.s @0 ; been already.
EraseRect SampleRect(A4)
@0 Move.w NameCell+v(A4),D0 ; Update the font number in
Bmi.s @1 ; TempFont with the number
Mulu #6,D0 ; of the font selected .
Move.w 2(A3,D0.W),TempFont(A4)
Cmpi.w #0,TempSize(A4)
Beq.s @2
Bset.b #OkActive,DFlags(A4) ; Dialog selections are valid.
Bset.b #SUpdate,DFlags(A4) ; Sample Window requires updating.
Move.l Ticks,SampleTicks(A4)
Bra.s @3
@1 Move.w #-1,TempFont(A4) ; No Font Name is selected.
@2 Bclr.b #OkActive,DFlags(A4) ; Dialog selections aren't valid.
@3 Jsr LdSizes ; Update Font Size Selection Window.
GetDItem FontDPtr,#19,Itemtype(A4),Item(A4),ItemBox(A4)
EraseRect ItemBox(A4)
LMUpdate VisRgn(A4),SizeListH(A4)
Jmp WaitOk
FontSize
; The user has made a new selection from the Font Size Selection Window,
; either a new font name or none. TempSize might not change.
Move.w TempSize(A4),D2 ; Store for comparison later.
Move.w NameCell+v(A4),D0
Bmi.s @0 ; No Font Name selected.
Mulu #6,D0
Move.w 2+4(A3,D0.W),D0 ; Offset to the font's size list.
Lea (A3,D0.W),A0 ; Address of the size list.
Move.w SizeCell+v(A4),D0
Bmi.s @0 ; No Font Size selected.
Lsl.w #1,D0
Move.w 2(A0,D0.W),TempSize(A4) ; Store new font size.
Cmp.w TempSize(A4),D2 ; Has the size altered?
Beq.s @0 ; No -> @0
Jsr SetEditSize ; Update the textedit window.
@0 Jmp WaitOk
GetEditSize
; Convert the text in the font size text edit window into a number to update
; TempSize. TempSize might not have changed, if the mouse is
; clicked within the font size text edit window this routine is called.
GetDItem FontDPtr,#20,Itemtype(A4),Item(A4),ItemBox(A4)
GetIText Item(A4),thename(A4)
Lea thename(A4),A0
_StringToNum
Cmpi.w #4,D0
Blt @2 ; if <4
Cmpi.w #127,D0
Bgt @2 ; if >127
Cmp.w TempSize(A4),D0 ; Has the size altered?
Beq.s @1 ; No -> @1
Move.w D0,TempSize(A4) ; Yes -> update TempSize.
Cmp.w #-1,TempFont(A4) ; Is there a valid font name?
Beq.s @3 ; No -> @3
Bset.b #OkActive,DFlags(A4) ; Dialog selections are valid.
Bclr.b #SRect,DFlags(A4) ; Erase the Sample Rect if it hasn't
Beq.s @0 ; been already.
EraseRect SampleRect(A4)
@0 Bset.b #SUpdate,DFlags(A4) ; Sample Window requires updating.
Move.l Ticks,SampleTicks(A4)
@1 Jmp WaitOk
@2 Clr.w TempSize(A4) ; Indicate its outside limits.
@3 Bclr.b #OkActive,DFlags(A4) ; Dialog selections aren't valid.
Bclr.b #SRect,DFlags(A4) ; Erase the Sample Rect if it hasn't
Beq.s @4 ; been already.
EraseRect SampleRect(A4)
@4 Jmp WaitOk
FontSample
Jsr SampleWindow ; update the attributes
TEUpdate SampleRect(A4),Sample(A4)
Bclr.b #SUpdate,DFlags(A4) ; Sample Window has been updated.
Bset.b #SRect,DFlags(A4) ; Sample Rect isn't blank.
Jmp WaitOk
SetEditSize
; Setup the font size text edit item. To access this routine there must be a valid
; font name.
GetDItem FontDPtr,#20,Itemtype(A4),Item(A4),ItemBox(A4)
Clr.l D7
Move.w TempSize(A4),D7
Cmpi.w #4,D7
Blt @1 ; if <4
Cmpi.w #127,D7
Bgt @1 ; if >127
Bset.b #OkActive,DFlags(A4) ; Dialog selections are valid.
Bclr.b #SRect,DFlags(A4) ; Erase the Sample Rect if it hasn't
Beq.s @0 ; been already.
EraseRect SampleRect(A4)
@0 Bset.b #SUpdate,DFlags(A4) ; Sample Window requires updating.
Move.l Ticks,SampleTicks(A4)
Lea thename(A4),A0 ; Load thename pointer.
Move.l D7,D0
_NumToString
Move.l Item(A4),-(SP) ; Set the item text to the new
Move.l A0,-(SP) ; number string.
_SetIText
; Procedure SelIText (theDialog: DialogPtr; itemNo: Integer;
; strtSel,endSel: Integer);
Move.l FontDPtr,-(SP)
Move.w #20,-(SP) ; Select the complete text in the item.
Move.w #0,-(SP)
Move.w #255,-(SP)
_SelIText
Rts
@1 Clr.w TempSize(A4) ; Indicate it's outside limits.
Bclr.b #OkActive,DFlags(A4) ; Dialog selections aren't valid.
Bclr.b #SRect,DFlags(A4) ; Erase the Sample Rect if it hasn't
Beq.s @2 ; been already.
EraseRect SampleRect(A4)
@2 Rts
LdNames
; Load the NameList with the font names stored in FontMap.
; Function LAddRow (count, rowNum: Integer; lHandle: ListHandle): Integer
Subq.l #2,SP
Move.w (A3),-(SP) ; The number of font names - 1.
Move.w #0,-(SP)
Move.l NameListH(A4),-(SP)
_LAddRow
Addq.l #2,SP
Clr.w D7 ; Loop counter (the # of fonts -1).
@0 Move.w D7,D6
Mulu #6,D6 ; Point to the next font info.
Move.w 2(A3,D6.W),D0 ; Obtain the font's number.
Cmp.w TempFont(A4),D0 ; Is this the font to be selected?
Bne.s @1 ; No -> @1.
Move.w D7,NameCell+v(A4) ; Store the cell # into NameCell+v.
@1 Move.w 2+2(A3,D6.W),D6 ; Obtain the font's name offset.
; Procedure LSetCell (dataPtr: Ptr; dataLen: Integer; theCell: Cell;
; lHandle: ListHandle)
Pea 1(A3,D6.W) ; Address of the name (string).
Clr.w D0
Move.b (A3,D6.W),D0 ; Length of the name.
Move.w D0,-(SP)
Move.w #0,-(SP) ; Cell column #.
Move.w D7,-(SP) ; Cell row #.
Move.l NameListH(A4),-(SP)
_LSetCell
Addq.w #1,D7 ; Increment the loop counter.
Cmp.w (A3),D7 ; Loaded all font names yet?
Ble.s @0 ; No -> @0.
; Select the cell containing the font name which corresponds to the font number passed to the
; FontDialog Routine. If the font number isn't associated with one of the fonts on the
; current system file then don't select any name.
Cmpi.w #-1,NameCell+v(A4) ; Cell to be selected?
Beq.s @2 ; No -> @2
LMSetSelect #True,NameCell(A4),NameListH(A4)
DeRefHndle NameListH(A4),A0 ; Scroll if the selected cell isn't
Move.w visible+bottom(A0),D6 ; visible, ie the last visible cell is
Cmp.w NameCell+v(A4),D6 ; less than the selected cell.
Bgt.s @2
LMAutoScroll NameListH(A4)
@2 LMDoDraw #True,NameListH(A4) ; Drawing on.
Rts
LdSizes
; load the SizeList with the font sizes of TempFont stored in FontMap.
LMDoDraw #False,SizeListH(A4) ; Drawing off.
LMDelRow #0,#0,SizeListH(A4) ; Delete all the rows.
Move.l #$FFFF0000,SizeCell(A4)
Move.w TempFont(A4),D4 ;The font number.
Bmi @5 ; -ve, no font number was passed to FontDialog.
Clr.w D7 ; Loop counter.
@1 Move.w D7,D6
Mulu #6,D6 ; Point to the next font info.
; Compare the font number with the font number that was passed to the FontDialog Routine.
Cmp.w 2(A3,D6.W),D4 ; Match?
Beq.s @2 ; Yes -> @2.
Addq.w #1,D7 ; Increment the loop counter.
Cmp.w (A3),D7 ; Looked at all the font numbers yet?
Ble.s @1 ; No ->@1.
Bra @5 ; Yes & no match was found.
@2 Move.w 2+4(A3,D6.W),D7 ; Offset to the font size list.
Move.w (A3,D7.W),D6 ; The number of font sizes.
; Procedure LAddRow (count, rowNum: Integer; lHandle: ListHandle): Integer
Subq.l #2,SP
Move.w D6,-(SP) ; Number of rows to add.
Move.w #0,-(SP)
Move.l SizeListH(A4),-(SP)
_LAddRow
Addq.l #2,SP
Clr.w D6 ; Setup the loop counter.
@3 Move.w D6,D5 ; Create an offset within the size list.
Lsl.w #1,D5
Add.w D7,D5 ; Offset from the start of FontMap.
Clr.l D0 ; Clear .L for NumToString.
Move.w 2(A3,D5.W),D0 ; A font size.
Cmp.w TempSize(A4),D0 ; Is this the selected size?
Bne.s @4 ; No -> @4.
Move.w D6,SizeCell+v(A4) ; Store the cell number to be selected.
@4 Lea thename(A4),A0
_NumToString
; Procedure LSetCell (dataPtr: Ptr; dataLen: Integer; theCell: Cell;
; lHandle: ListHandle)
Pea 1(A0) ; Address of the Size (string).
Clr.w D0
Move.b (A0),D0 ; Length of the Size.
Move.w D0,-(SP)
Move.w #0,-(SP) ; Cell column #.
Move.w D6,-(SP) ; Cell row #.
Move.l SizeListH(A4),-(SP)
_LSetCell
Addq.w #1,D6 ; Increment the loop counter.
Cmp.w (A3,D7.W),D6 ; Loaded all font sizes yet?
Blt.s @3 ; No -> @3.
; Select the cell containing the font size which corresponds to the font size passed to the
; FontDialog Routine. If the font doesn't have the size selected, do nothing.
Cmpi.w #-1,SizeCell+v(A4) ; Cell to be selected?
Beq.s @5 ; No -> @5
LMSetSelect #True,SizeCell(A4),SizeListH(A4)
DeRefHndle SizeListH(A4),A0 ; Scroll if the selected cell isn't
Move.l (A0),A0 ; visible, ie the last visible cell is
Move.w visible+bottom(A0),D6 ; less than the selected cell.
Cmp.w SizeCell+v(A4),D6
Bgt.s @5
LMAutoScroll SizeListH(A4)
@5 LMDoDraw #True,SizeListH(A4) ; Drawing on.
Rts
SampleWindow
; Update the sample TextEdit Record with the currently
; selected font attributes.
Btst.b #OkActive,DFlags(A4) ; Are the selections valid?
Beq @0 ; No -> @0
TextFont TempFont(A4) ; Font number
TextFace TempFace(A4) ; Font style
TextSize TempSize(A4) ; Font size
GetFontInfo info(A4)
DeRefHndle Sample(A4),A0
Move.w TempFont(A4),teFont(A0) ; teFont
Move.b TempFace+1(A4),teFace(A0) ; teFace
Move.w TempSize(A4),teSize(A0) ; teSize
Move.w info+ascent(A4),teAscent(A0) ; teAscent
Move.w info+ascent(A4),D0 ; teLineHite
Add.w info+descent(A4),D0
Add.w info+leading(A4),D0
Move.w D0,teLineHite(A0)
Move.l teViewRect+topLeft(A0),teDestRect+topLeft(A0)
Move.l teViewRect+botRight(A0),teDestRect+botRight(A0)
Mulu teNLines(A0) ,D0 ; Height of the sample text.
Move.w SampleRect+bottom(A4),D1
Sub.w SampleRect+top(A4),D1
Cmp.w D0,D1 ; Sample greater than Rect?
Ble @0 ; Yes -> @0
Sub.w D0,D1 ; Center the sample
Lsr.w #1,D1 ; lines in the middle
Add.w D1,teDestRect+top(A0) ; of SampleRect.
@0 Rts
; --------------------- Modal Dialog User Filter ---------------------------
DUserFilter
Link A6,#0
; Boolean result 20(A6)
; Dialog (window) pointer 16(A6)
; Address of the event record 12(A6)
; Address of word to fill in with item number 8(A6)
; Return address 4(A6)
; Old A6 (A6)
; Use the event number as an index into the DEventTable. These 12 events are
; all the things that could spontaneously happen while the program is in
; the Modal Dialog event loop.
Movea.l 16(A6),A4 ; Font Dialog Data Record.
Move.w #False,20(A6) ; Set the function result to False.
Movea.l 12(A6),A0 ; Event Records Address.
Move.w evtNum(A0),D0 ; Get the event number.
Lsl.w #1,D0 ; *2 for table index.
Move.w DEventTable(D0.W),D0 ; Point to the routine offset
Jmp DEventTable(D0.W) ; and jump to it.
DEventTable
Dc.w DNull-DEventTable ; Null
Dc.w DMouseDown-DEventTable ; Mouse Down
Dc.w DFReturn-DEventTable ; Mouse Up (Not used)
Dc.w DKeyDown-DEventTable ; Key Down
Dc.w DFReturn-DEventTable ; Key Up (Not used)
Dc.w DKeyDown-DEventTable ; Auto Key
Dc.w DUpdate-DEventTable ; Update
Dc.w DFReturn-DEventTable ; Disk (Not used)
Dc.w DActivate-DEventTable ; Activate
Dc.w DFReturn-DEventTable ; Network (Not used)
Dc.w DFReturn-DEventTable ; I/O Driver (Not used)
DNull
GetDItem 16(A6),#20,Itemtype(A4),Item(A4),ItemBox(A4)
GetMouse loc_pt(A4)
PtInRect loc_pt(A4),ItemBox(A4) ; Was the mouse within the
Move.b (SP)+,D0 ; FontSize text edit Rect?
Beq.s @0 ; Yes -> iBeam cursor.
; Procedure SetCursor (crsr: Cursor)
Move.l TextCursor(A4),A0
Move.l (A0),-(SP)
_SetCursor
Bra @1
@0 _InitCursor ; No -> Arrow cursor.
@1 Move.l Ticks,D0 ; If KeyTresh Ticks have passed
Sub.l SampleTicks(A4),D0 ; since the last item alteration,
Cmp.w KeyThresh,D0 ; update the sample window by
Blt DFReturn ; indicating item #21 was hit.
Btst.b #SUpdate,DFlags(A4)
Beq DFReturn
Move.w #21,D0 ; Set the itemNo to 21, Sample
Bra DFTReturn
DMouseDown
Bclr.b #SKey,DFlags(A4) ; Not a SKey event.
; Obtain the (events) mouse location and convert it to local coordinates.
Move.l evtMouse(A0),loc_pt(A4)
GlobalToLocal loc_pt(A4)
; Check to see if the mouse was clicked inside one of the active rectangles.
Item9
;- Check to see if the mouse was pressed down within item No 9 (Style heading)
GetDItem FontDPtr,#9,Itemtype(A4),Item(A4),ItemBox(A4)
PtInRect loc_pt(A4),ItemBox(A4)
Move.b (SP)+,D0 ; Was the point within the heading?
Beq.s Item14 ; No -> check item No 14's Rect.
; Routine TrackHeading (theDialog: DialogPtr; itemNo: Integer): Boolean
Subq.l #2,SP ; Set up for the result.
Move.l FontDPtr,-(SP)
Move.w #9,-(SP)
Bsr TrackHeading
Move.b (SP)+,D0 ; Was the mouse up within the item?
Beq SetoNull ; No, Convert the event to null & return .
Move.w #9,D0 ; Yes, return True & the item No 9.
Bra DFTReturn
Item14
;- Check to see if the mouse was pressed down within item No 14 (Spacing heading).
GetDItem FontDPtr,#14,Itemtype(A4),Item(A4),ItemBox(A4)
PtInRect loc_pt(A4),ItemBox(A4)
Move.b (SP)+,D0 ; Was the point within the heading?
Beq Item17 ; No -> check item No 17's Rect.
; Routine TrackHeading (theDialog: DialogPtr; itemNo: Integer): Boolean;
Subq.l #2,SP
Move.l FontDPtr,-(SP)
Move.w #14,-(SP)
Bsr TrackHeading
Move.b (SP)+,D0 ; Was the mouse up within the item?
Beq SetoNull ; No, Convert the event to null & return .
Move.w #14,D0 ; Yes, return True & the item No 14.
Bra DFTReturn
Item17
; Check to see if the mouse was pressed down within item No 17
; The Font Name Selection Window.
GetDItem FontDPtr,#17,Itemtype(A4),Item(A4),ItemBox(A4)
Addi.w #15,ItemBox+right(A4) ; include the vertical scroll bar.
PtInRect loc_pt(A4),ItemBox(A4)
Move.b (SP)+,D0 ; Was the point within the rect?
Beq Item19 ; No -> check item No 19's rect.
; If a new selection is made return true and the item number, otherwise
; set the event to a null event and return.
; Function LClick (pt: Point; modifiers: Integer; lHandle: ListHandle): Boolean
Subq.l #2,SP
Move.l loc_pt(A4),-(SP)
Movea.l 12(A6),A0
Move.w evtMeta(A0),-(SP)
Move.l NameListH(A4),-(SP)
_LClick
Addq.l #2,SP
Clr.l TempCell(A4)
LMGetSelect #True,TempCell(A4),NameListH(A4)
Move.b (SP)+,D0 ; Is there a selected cell?
Bne @0 ; Yes -> @0.
Move.l #$FFFF0000,TempCell(A4) ; No set TempCell to 0,-1.
@0 Move.l TempCell(A4),D0 ; Has the selected cell changed?
Cmp.l NameCell(A4),D0
Beq SetoNull ; No -> SetoNull.
Move.l D0,NameCell(A4) ; Yes, return True & the item No 17.
Move.w #17,D0
Bra DFTReturn
Item19
; Check to see if the mouse was pressed down within item No 19.
; The Font Size Selection Window.
GetDItem FontDPtr,#19,Itemtype(A4),Item(A4),ItemBox(A4)
Addi.w #15,ItemBox+right(A4) ; Include the vertical scroll bar.
PtInRect loc_pt(A4),ItemBox(A4)
Move.b (SP)+,D0 ; Was the point within the rect?
Beq DFReturn ; No -> DFReturn.
; If a new selection is made return true and the item number, otherwise
; set the event to a null event and return.
; Function LClick (pt: Point; modifiers: Integer; lHandle: ListHandle): Boolean
Subq.l #2,SP
Move.l loc_pt(A4),-(SP)
Movea.l 12(A6),A0
Move.w evtMeta(A0),-(SP)
Move.l SizeListH(A4),-(SP)
_LClick
Addq.l #2,SP
Clr.l TempCell(A4)
LMGetSelect #True,TempCell(A4),SizeListH(A4)
Move.b (SP)+,D0 ; Is there a selected cell?
Bne @0 ; Yes -> @0.
Move.l #$FFFF0000,TempCell(A4)
@0 Move.l TempCell(A4),D0 ; Has the selected cell changed?
Cmp.l SizeCell(A4),D0
Beq SetoNull ; No -> SetoNull.
Move.l D0,SizeCell(A4) ; Yes, return True & the item No 19.
Move.w #19,D0
Bra DFTReturn
DKeyDown
; Examine the key that was pressed, if it was a 'cr' or 'enter' then that is
; equivalent to clicking the Ok button.
Move.l evtMessage(A0),D0
Cmpi.b #crCode,D0 ; Was the cr key pressed?
Beq.s @1 ; Yes -> @1.
Cmpi.b #enterCode,D0 ; Was the enter key pressed?
Bne.s @2 ; No -> @2.
@1 Move.w #1,D0 ; Set the item No to the Ok button.
Bra DFTReturn ; Item No 1 - Ok.
@2 ; If the key pressed was the back space key or a number then deselect
; the cell in the Font Size Selection Window (if there is one selected),
; then return, allowing the number or 'bs' to be used to alter the FontSize
; text edit data.
Cmpi.b #bsCode,D0 ; Was the bs key pressed?
Beq.s @3 ; Yes -> @3.
Cmpi.b #$30,D0
Blt.s NameSearch
Cmpi.b #$39,D0
Bgt.s NameSearch
@3 Bclr.b #SKey,DFlags(A4) ; Not a SKey event.
Cmpi.l #$FFFF0000,SizeCell(A4) ; If a cell is selected,
Beq DFReturn ; deselect it, then let
LMSetSelect #False,SizeCell(A4),SizeListH(A4) ; the default routine
Move.l #$FFFF0000,SizeCell(A4) ; handle the event.
Bra DFReturn
NameSearch
Lea search(A4),A2
Bset.b #SKey,DFlags(A4) ; Was the last event a SKey event?
Beq.s @0 ; No -> @0
Move.l evtTicks(A0),D1 ; Yes -> If this key down occured
Sub.l SampleTicks(A4),D1 ; within KeyThresh Ticks of the last
Cmp.w KeyThresh,D1 ; continue the search string
Blt.s @1 ; else, reset the search string.
@0 Clr.b (A2) ; Continue.
@1 Addq.b #1,(A2) ; Reset.
Move.l evtTicks(A0),SampleTicks(A4)
Clr.w D1 ; If search string is greater than
Move.b (A2),D1 ; 32, SetoNull.
Cmpi.b #31,D1
Bgt SetoNull
Move.b D0,(A2,D1.w) ; Add char to string.
DeRefHndle FontMap(A5),A3
Clr.w D7 ; Set loop counter.
@2 Move.w D7,D6
Mulu #6,D6 ; Offset to next font info.
Move.w 2+2(A3,D6.w),D6 ; Offset to name string.
; Function IUMagString (aPtr, bPtr: Ptr; aLen, bLen: Integer): Integer
Subq.l #2,SP
Pea 1(A3,D6.w) ; Address of FontName string.
Pea 1(A2) ; Address of search string.
Clr.w D0
Move.b (A3,D6.w),D0
Move.w D0,-(SP) ; Length of FontName string.
Move.b (A2),D0
Move.w D0,-(SP) ; Length of search string.
_IUMagString
Move.w (SP)+,D0 ; Was the FontName => ?
Bpl.s @3 ; Yes -> @3
Addq.w #1,D7 ; Have all the fonts been
Cmp.w (A3),D7 ; looked at?
Blt @2 ; No -> @2
@3 ; Is the desired cell selected?
; Yes -> Don't do anything.
; No -> Deselect the existing cell & select the new cell.
Cmp.w NameCell+v(A4),D7
Beq SetoNull
LMSetSelect #False,NameCell(A4),NameListH(A4)
Move.w D7,NameCell+v(A4)
LMSetSelect #True,NameCell(A4),NameListH(A4)
DeRefHndle NameListH(A4),A0 ; If the selected cell isn't visible
Cmp.w visible+top(A0),D7 ; then AutoScroll.
Blt.s @4 ; else continue.
Cmp.w visible+bottom(A0),D7
Blt.s @5
@4 LMAutoScroll NameListH(A4)
@5 Move.w #17,D0
Bra DFTReturn
DUpdate
Bclr.b #SKey,DFlags(A4) ; Not a SKey event.
SetPort FontDPtr
BeginUpdate FontDPtr
DrawControls FontDPtr
;-*- Update itemNo 1 -------------------------------------------------------
; The BoldBox around the Ok button.
GetDItem FontDPtr,#1,Itemtype(A4),Item(A4),ItemBox(A4)
InsetRect ItemBox(A4),#-4,#-4
PenSize #3,#3
FrameRoundRect ItemBox(A4),#16,#16
_PenNormal
;-*- Update itemNo 3 -------------------------------------------------------
; The Static Text heading "Character Font & Attributes".
GetDItem FontDPtr,#3,Itemtype(A4),Item(A4),ItemBox(A4)
GetIText Item(A4),thename(A4)
Lea thename(A4),A0 ; Address of the text.
Clr.l D0
Move.b (A0)+,D0 ; Length of the text.
TextBox A0,D0,ItemBox(A4),#0
;-*- Update the Font Style Selection Window --------------------------------
; The ThinBox around the Style Check Boxes (item No 10).
GetDItem FontDPtr,#10,Itemtype(A4),Item(A4),ItemBox(A4)
FrameRect ItemBox(A4)
; The Static Text heading "Style" (item No 9).
GetDItem FontDPtr,#9,Itemtype(A4),Item(A4),ItemBox(A4)
GetIText Item(A4),thename(A4)
Lea thename(A4),A0 ; Address of the text.
Clr.l D0
Move.b (A0)+,D0 ; Length of the text.
TextBox A0,D0,ItemBox(A4),#0
;-*- Update the Font Spacing Selection Window --------------------------------
; The ThinBox around the Style Check Boxes (item No 15).
GetDItem FontDPtr,#15,Itemtype(A4),Item(A4),ItemBox(A4)
FrameRect ItemBox(A4)
; The static text heading "Spacing" (item No 14).
GetDItem FontDPtr,#14,Itemtype(A4),Item(A4),ItemBox(A4)
GetIText Item(A4),thename(A4)
Lea thename(A4),A0 ; Address of the text.
Clr.l D0
Move.b (A0)+,D0 ; Length of the text.
TextBox A0,D0,ItemBox(A4),#0
;-*- Update itemNo 16 ------------------------------------------------------
; The Static Text heading "Font Name:".
GetDItem FontDPtr,#16,Itemtype(A4),Item(A4),ItemBox(A4)
GetIText Item(A4),thename(A4)
Lea thename(A4),A0 ; Address of the text.
Clr.l D0
Move.b (A0)+,D0 ; Length of the text.
TextBox A0,D0,ItemBox(A4),#0
;-*- Update itemNo 17 ------------------------------------------------------
; The Font Name Selection Window.
GetDItem FontDPtr,#17,Itemtype(A4),Item(A4),ItemBox(A4)
InsetRect ItemBox(A4),#-1,#-1
EraseRect ItemBox(A4)
FrameRect ItemBox(A4)
LMUpdate VisRgn(A4),NameListH(A4)
;-*- Update itemNo 18 ------------------------------------------------------
; The Static Text heading "Font Size:".
GetDItem FontDPtr,#18,Itemtype(A4),Item(A4),ItemBox(A4)
GetIText Item(A4),thename(A4)
Lea thename(A4),A0 ; Address of the text.
Clr.l D0
Move.b (A0)+,D0 ; Length of the text.
TextBox A0,D0,ItemBox(A4),#0
;-*- Update itemNo 19 ------------------------------------------------------
; The Font Size Selection Window.
GetDItem FontDPtr,#19,Itemtype(A4),Item(A4),ItemBox(A4)
InsetRect ItemBox(A4),#-1,#-1
EraseRect ItemBox(A4)
FrameRect ItemBox(A4)
LMUpdate VisRgn(A4),SizeListH(A4)
;-*- Update itemNo 20 ------------------------------------------------------
; The TextEdit text item.
GetDItem FontDPtr,#20,Itemtype(A4),Item(A4),ItemBox(A4)
EraseRect ItemBox(A4)
TEUpdate ItemBox(A4),teHandle(A4)
InsetRect ItemBox(A4),#-3,#-3
FrameRect ItemBox(A4) ; Frame the textedit item.
;-*- Update itemNo 21 ------------------------------------------------------
; Update the Sample Text Window.
EraseRect SampleRect(A4)
Bclr.b #SRect,DFlags(A4)
Btst.b #OkActive,DFlags(A4) ; Are the selections valid?
Beq @0 ; No -> @0
TEUpdate SampleRect(A4),Sample(A4) ; Yes -> update the sample
Move.l Ticks,SampleTicks(A4) ; and associated
Bclr.b #SUpdate,DFlags(A4) ; variables.
Bset.b #SRect,DFlags(A4)
@0 EndUpdate FontDPtr
Bra SetoNull
DActivate
; Check first to see if this activate event is associated with this Dialog
; Window, compare the Dialog Window's pointer to that of the Window pointer
; in the event record. A0 contains the address of the event record.
Move.l FontDPtr,D0
Cmp.l evtMessage(A0),D0
Bne DFReturn ; Event not related to Dialog.
Bclr.b #SKey,DFlags(A4) ; Not a SKey event.
SetPort FontDPtr
Movea.l 12(A6),A0 ; Address of the event record.
Move.w evtMeta(A0),D0 ; Obtain the modify word.
Lsr #1,D0 ; Check Bit 0 to see if its
Bcc DDeactivate ; Activate or Deactivate.
TEActivate teHandle(A4)
LMActivate #True,NameListH(A4)
LMActivate #True,SizeListH(A4)
Bra SetoNull
DDeactivate
TEDeactivate teHandle(A4)
LMActivate #False,NameListH(A4)
LMActivate #False,SizeListH(A4)
Bra SetoNull
SetoNull
Movea.l 12(A6),A0 ; Obtain the address of the Event
Clr.w evtNum(A0) ; Record & set it to a null event.
Bra.s DFReturn
DFTReturn
Move.b #True,20(A6) ; Dialog Filter (True) Return.
Movea.l 8(A6),A0
Move.w D0,(A0)
DFReturn ; Dialog Filter Return.
Unlk A6
Movea.l (SP)+,A0 ; Pop args & return.
Add.l #12,SP
Jmp (A0)
TrackHeading
Link A6,#-22
; Boolean result 14(A6)
; theDialog pointer 10(A6)
; itemNo 8(A6)
; Return address 4(A6)
; Old A6 (A6)
; Temporary Region Handle No1 -4(A6)
; Temporary Region Handle No2 -8(A6)
; Vis boolean -10(A6)
; Mouse Location -14(A6)
; Temporary Rectangle -22(A6)
Move.b #False,14(A6) ; Set up to return False.
;- Get the Rect of the user item that surrounds the headings control items
; (check boxes or radio buttons).
Addq.w #1,8(A6)
GetDItem 10(A6),8(A6),Itemtype(A4),Item(A4),-22(A6)
;- Create a region and store in it the current clipping region.
NewRgn
Move.l (SP),-4(A6) ; Store the regions handle.
_GetClip
;- Create a new clipping region which is the user item's rect inset by 1 pixel
; on all sides minus the intersection rectangle of the heading's rect
; and the newly created rect.
NewRgn
Move.l (SP),-8(A6) ; Store the regions handle.
InsetRect -22(A6),#1,#1
_OpenRgn
FrameRect -22(A6)
;- Find the rectangle that is the intersection of ItemBox(A4) and -22(A6).
; If they intersect then remove that rectangle from the clipping region.
SectRect ItemBox(A4),-22(A6),TempRect
Move.b (SP)+,D0 ; Was there an intersection?
Beq.s @1 ; No -> @1.
FrameRect TempRect
@1 _CloseRgn ; The handle is already on the stack.
SetClip -8(A6) ; Set up the new clipping region.
PenSize #1,#1
PenMode #10 ; Inverts what ever is drawn over.
; Draw the rectangle in question, giving the user the impression that they
; have selected the heading.
FrameRect -22(A6)
Move.b #True,-10(A6) ; Set the vis byte to True.
Track
StillDown
Move.b (SP)+,D0 ; Is the mouse button still down?
Beq @1 ; No -> @1.
GetMouse -14(A6)
PtInRect -14(A6),ItemBox(A4)
Move.b (SP)+,D0 ; Has the mouse entered or
Cmp.b -10(A6),D0 ; left the item's rect?
Beq.s Track ; No -> Track.
FrameRect -22(A6) ; Yes -> toggle the rectangle.
Eori.b #1,-10(A6) ; Toggle the visible byte.
Bra.s Track
@1 Move.b -10(A6),D0 ; Is the rect visible?
Beq.s @2 ; No -> Return False.
FrameRect -22(A6) ; Yes -> Remove the rectangle &
Move.b #True,14(A6) ; return True.
@2 _PenNormal
SetClip -4(A6) ; Reset to its original setting.
DisposeRgn -4(A6) ; Dispose of the two temporary regions.
DisposeRgn -8(A6)
Unlk A6
Movea.l (SP)+,A0 ; Pop args & return.
Add.l #6,SP
Jmp (A0)
; ---------- Variables ------
FontDRec Ds.l 1